package com.example.poemtest.index.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * created by JHT on 2024/5/9
 */
public class CustomImageButton extends androidx.appcompat.widget.AppCompatImageButton {
    private TextView textView;

    public CustomImageButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        //初始化TextView用于长按时显示文字
        textView = new TextView(context);
        textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    }

    public boolean onLongClick(String dynasty) {
        textView.setText(dynasty);
        return true;
    }
}
